import Request from './request';
let loadNum = 0;
Request.interceptors.request((res) => {
    if (loadNum === 0) {
        uni.showLoading({
            title: '加载中'
        });
    }
    loadNum += 1;
    console.log(loadNum);
    return res
})
Request.interceptors.response((res) => {
    loadNum--;
    if (loadNum === 0) {
        uni.hideLoading();
    }
    console.log(loadNum);
    return res
})
Request.install = function (Vue) {
    Object.defineProperty(Vue.prototype, '$request', {
        get: function () {
            return Request
        }
    })
}

export default Request